﻿@using System.Data;
@using BootstrapBlazor.Components
@inherits WidgetComponentBase

<form>
    <div class="form-group">
        <Select OnQueryAsync="OnQueryAsync" @bind-Value="@(Component.Props["DataSourse"].StringValue)"></Select>
    </div>
</form>


@code {

    protected override Task OnInitializedAsync()
    {
        return base.OnInitializedAsync();
    }

    private async Task<QueryData<SelectedItem>> OnQueryAsync(VirtualizeQueryOption option)
    {
        await Task.Delay(200);
        //var items = Foos;
        //if (!string.IsNullOrEmpty(option.SearchText))
        //{
        //    items = items.Where(i => i.Name!.Contains(option.SearchText, StringComparison.OrdinalIgnoreCase)).ToList();
        //}
        return new QueryData<SelectedItem>
            {
                Items = new List<SelectedItem>()
                        {
                    new SelectedItem("Beijing", "北京"),
                    new SelectedItem("Shanghai", "上海") { Active = true },
                },

                // Items = items.Skip(option.StartIndex).Take(option.Count).Select(i => new SelectedItem(i.Name!, i.Name!)),
                TotalCount = 2
            };
    }
}
